05. Java Basic APIs - Binary Search, Recursion, Big-O Notation
Binary Search
035ND C01 L01 A04 BINARY SEARCH
Binary Search Coding Exercise
Task Description:
Please complete the coding questions using binary search.
Search for the target in a sorted array, and return the index. If the target is not in this array, return -1.
Example:
Input: [1, 5, 7, 8, 9, 11, 18, 19, 20, 25], target=11, output=5.
Input: [1, 2, 3, 4, 5], target=10, output=-1
public static int findTarget(int[] arr, int target) {
}
Task Feedback:
Great! Check my solution here: Github: https://github.com/udacity/JDND/tree/master/exercises/c1/exercises
Recursion
035ND C01 L01 A05 RECURSION
Recursion Exercise
Task Description:
Write a permutation of [1, 2, 3] (permutation gives several possible variations, in which a set or number of things can be ordered or arranged).
Give an array with unique integers, print all permutations.
Example
Input: [1, 2], print 12, 21
Input: [1, 2, 3], print 123, 132, 213, 231, 312, 321.
public static void printPermutn(int[] arr, int index) {
}
Task Feedback:
Solution: https://github.com/udacity/JDND/tree/master/exercises/c1/exercises
Big-O Notation
035ND C01 L01 A06 BIG O NOTATION
Check the following link for a quick summary of the time complexity:
Big-O Notation Quiz1
SOLUTION:
O(m * n)Big-O Notation Quiz2